package vcsn.ui;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class InputDialog extends Dialog {
    private Text inputField;
    private String inputString;
    private String header;

    public InputDialog(Shell parentShell) {
        super(parentShell);
    }
    
    @Override
    protected void configureShell(Shell newShell)
    {
        super.configureShell(newShell);
        newShell.setText(header);
        newShell.setSize(500, 200);
        newShell.setLocation(300, 200);
    }
    

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite comp = (Composite) super.createDialogArea(parent);

        GridLayout layout = (GridLayout) comp.getLayout();
        layout.numColumns = 2;

//        Label passwordLabel = new Label(comp, SWT.RIGHT);
//        passwordLabel.setText("Commit Message: ");
        inputField = new Text(comp, SWT.SINGLE | SWT.BORDER);

        GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
        data.heightHint = 150;
        data.widthHint = 200;
        inputField.setLayoutData(data);

        return comp;
    }

    @Override
    protected void okPressed()
    {
        inputString = inputField.getText();
        super.okPressed();
    }

    @Override
    protected void cancelPressed()
    {
        inputField.setText("");
        super.cancelPressed();
    }

    public String getInputString()
    {
        return inputString;
    }
    
    public void setHeader(String header){
    	this.header = header;
    }
}
